#ifndef GLOBAL_H
#define GLOBAL_H

#include "../Base.h"
#include "../../cs2 dumper/offsets.hpp"

class Global
{
public:
	static void Setup()
	{
		client.dll = (uintptr_t)GetModuleHandleA("client.dll");
	}

	template<class T>
	static T GetEntityHandleFrom(int Handle)
	{
		uintptr_t List = Memory::Read<uintptr_t>((uintptr_t)EntityList() + 0x8 * ((Handle & 0x7FFF) >> 9) + 0x10);
		return Memory::Read<T>(List + 0x78 * (Handle & 0x1FF));
	}

	static void* EntityList()
	{
		return (void*)Memory::Read<uintptr_t>(client.dll + cs2_dumper::offsets::client_dll::dwEntityList);
	}

	static std::string GetEntityName(uintptr_t Entity)
	{
		return Memory::ReadString(Memory::Read<uintptr_t>(Memory::Read<uintptr_t>(Entity + 0x10) + 0x20) + 0x0);
	}
};

#endif //GLOBAL_H